//
//  XNBillInfoTableViewCell.m
//  XINNingOA
//
//  Created by 葛承铭 on 2021/7/11.
//

#import "XNBillInfoTableViewCell.h"

@interface XNBillInfoTableViewCell()

@property (nonatomic, weak) UILabel *billNumberLab;

@property (nonatomic, weak) UILabel *billTypeLab;

@property (nonatomic, weak) UILabel *billCreaterLab;

@property (nonatomic, weak) UILabel *billCreatTimeLab;

@end

@implementation XNBillInfoTableViewCell

+ (instancetype)tabelViewCellWithTableView:(UITableView *)tableView
                                  ForIndexPath:(NSIndexPath *)indexPath
{
    static NSString *cellID = @"XNBillInfoTableViewCellID";
    XNBillInfoTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if (cell == nil) {
        cell = [[XNBillInfoTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    return cell;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self == [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self setSubView];
    }
    return self;
}

- (void)setSubView
{
    UILabel *billNumberLab = [[UILabel alloc] init];
    billNumberLab.textColor = [UIColor colorWithHexString:@"#358AFF"];
    billNumberLab.font = [UIFont systemFontOfSize:18];
    [self.contentView addSubview:billNumberLab];
    self.billNumberLab = billNumberLab;
    [billNumberLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView).offset(20);
        make.right.equalTo(self.contentView).offset(-20);
        make.height.mas_equalTo(20);
        make.top.equalTo(self.contentView).offset(10);
    }];
    
    
    UILabel *billTypeLab = [[UILabel alloc] init];
    billTypeLab.textColor = [UIColor blackColor];
    billTypeLab.font = [UIFont systemFontOfSize:14];
    [self.contentView addSubview:billTypeLab];
    self.billTypeLab = billTypeLab;
    [billTypeLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView).offset(20);
        make.right.equalTo(self.contentView).offset(-20);
        make.height.mas_equalTo(16);
        make.top.equalTo(billNumberLab.mas_bottom).offset(8);
    }];
    
    
    UILabel *billCreaterLab = [[UILabel alloc] init];
    billCreaterLab.textColor = [UIColor blackColor];
    billCreaterLab.font = [UIFont systemFontOfSize:14];
    [self.contentView addSubview:billCreaterLab];
    self.billCreaterLab = billCreaterLab;
    [billCreaterLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView).offset(20);
        make.right.equalTo(self.contentView).offset(-20);
        make.height.mas_equalTo(16);
        make.top.equalTo(billTypeLab.mas_bottom).offset(8);
    }];
    
    UILabel *billCreatTimeLab = [[UILabel alloc] init];
    billCreatTimeLab.textColor = [UIColor blackColor];
    billCreatTimeLab.font = [UIFont systemFontOfSize:14];
    [self.contentView addSubview:billCreatTimeLab];
    self.billCreatTimeLab = billCreatTimeLab;
    [billCreatTimeLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView).offset(20);
        make.right.equalTo(self.contentView).offset(-20);
        make.height.mas_equalTo(16);
        make.top.equalTo(billCreaterLab.mas_bottom).offset(8);
    }];
    
    UILabel *line = [[UILabel alloc] init];
    line.backgroundColor = [UIColor colorWithHexString:@"#E0E0E0"];
    [self.contentView addSubview:line];
    [line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView).offset(20);
        make.bottom.equalTo(self.contentView);
        make.height.mas_equalTo(1);
        make.right.equalTo(self.contentView);
    }];
    
}

- (void)setItemModel:(XNBillItemModel *)itemModel
{
    _itemModel = itemModel;
    self.billNumberLab.text = itemModel.orderId;
    self.billTypeLab.text = [NSString stringWithFormat:@"单据类型:%@",itemModel.billName];
    self.billCreaterLab.text = [NSString stringWithFormat:@"发出人:%@",itemModel.applyName];
    self.billCreatTimeLab.text = [NSString stringWithFormat:@"发出时间:%@",itemModel.createTimeStr];
}




@end
